<!--引入头部数据-->
<?php include './head.php';
$cid=$_GET['cid'];
$sql="select * from bl_class where id=$cid";
$class=db_sel($sql);
if($class['pid']==0){
    $erclass=db_sel("select * from bl_class where pid=$cid",2);
}else{
    $flclass=db_sel("select * from bl_class where id='{$class['pid']}'");
    $erclass=db_sel("select * from bl_class where pid='{$class['pid']}'",2);
}

$limit=4;
$page=$_GET['page']?$_GET['page']:1;
$offset=($page-1)*$limit;
$count=db_sel("select count(*) as co from bl_wz where cid=$cid");
$cot=ceil($count['co']/$limit);
$syy=$page-1>0?$page-1:1;
$xyy=$page+1<=$cot?$page+1:$cot;

//分类文章
$sql="select w.*,c.name as cname,c.id as cfid from
(select w.*,c.name,c.pid from bl_wz as w join bl_class as c on w.cid=c.id where w.stat=1) as w
    left join bl_class as c on c.id = w.pid where w.cid=$cid limit $offset,$limit";

$arr=db_sel($sql,2);
//var_dump($arr);exit;
/**最新文章**/
$sql="select w.id,w.title from bl_wz as w left join bl_class as c on w.cid=c.id where c.pid={$_GET['cid']} or c.id={$_GET['cid']} order by w.time desc limit 5";
//$zxwz=db_sel($sql,2);
$data=zxwz($sql);

/**点击排行**/
$sql="select w.id,w.title from bl_wz as w left join bl_class as c on
 w.cid=c.id where {$_GET['cid']}=c.pid or
 c.id={$_GET['cid']} and w.stat=1 order by w.ydl desc limit 5";
$djph=djph($sql);
?>

<!--列表页独有样式-->
<link href="../public/home/css/style.css" rel="stylesheet">
<script src="../public/home/js/modernizr.js"></script>

<article class="blogs">
    <h1 class="t_nav"><span>“慢生活”不是懒惰，放慢速度不是拖延时间，而是让我们在生活中寻找到平衡。</span>
        <?php if($class['pid']==0){?>
        <a href="#" class="n1"><?php echo $class['name']?></a>
        <?php }else{?>
        <a href="./newlist.php?cid=<?php echo $flclass['id']?>" class="n1">
            <?php echo $flclass['name']?></a>
        <a href="#" class="n2"><?php echo $class['name']?></a>
        <?php }?>
    </h1>
    <div class="newblog left">
        <?php foreach($arr as $v){?>
            <h2><?php echo $v['title']?></h2>
            <p class="dateview">
                <span>&nbsp;发布时间:<?php echo '&nbsp;'.date('Y-m-d',$v['time'])?></span>
                <span>作者：<?php echo $v['user']?></span>
                <!--                判断 有无上级分类-->
                <span>
                <?php if($v['cname']){?>

                    [<a href="./newlist.php?cid=<?php echo $v['pid']?>"><?php echo $v['cname']?></a>]
                    [<a href="./newlist.php?cid=<?php echo $v['cid']?>"><?php echo $v['name']?></a>]
                </span>
                <?php }else{?>
                    <span>
                        <a href="./newlist.php?cid=<?php echo $v['cid']?>"><?php echo $v['name']?></a>
                    </span>
                <?php }?>
            </p>
            <figure><img src="<?php echo $v['img']?>"></figure>
            <ul>
                <p><?php echo $v['msg']?></p>
                <a title="/" href="./new.php?id=<?php echo $v['id']?>" target="_blank" class="readmore">阅读全文>></a>
            </ul>

            <div class="line"></div>
        <?php }?>


        <div class="blank"></div>

        <div class="page">
                <a href="./newlist.php?cid=<?php echo $_GET['cid'];?>&page=<?php echo $syy;?>"> <<< </a>
                <?php echo $page;?>
                <a href="./newlist.php?cid=<?php echo $_GET['cid'];?>&page=<?php echo $xyy;?>"> >>> </a>
        </div>
    </div>
    <aside class="right">
        <div class="rnav">
            <ul>
                <?php foreach($erclass as $v){?>
                <li class="rnav4"><a href="./newlist.php?cid=<?php echo $v['id']?>" target="_blank">
                        <?php echo $v['name']?></a></li>
                        <?php }?>
            </ul>
        </div>
        <div class="news">
            <?php echo $data?>

            <!--            点击排行-->
            <?php echo $djph?>
        </div>
        <div class="visitors">
            <h3><p>最近访客</p></h3>
            <ul>

            </ul>
        </div>
        <!-- Baidu Button BEGIN -->
        <div id="bdshare" class="bdshare_t bds_tools_32 get-codes-bdshare"><a class="bds_tsina"></a><a class="bds_qzone"></a><a class="bds_tqq"></a><a class="bds_renren"></a><span class="bds_more"></span><a class="shareCount"></a></div>
        <script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=6574585" ></script>
        <script type="text/javascript" id="bdshell_js"></script>
        <script type="text/javascript">
            document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
        </script>
        <!-- Baidu Button END -->
    </aside>
</article>
<footer>
    <p>Design by DanceSmile <a href="http://www.mycodes.net/" title="源码之家" target="_blank">源码之家</a> <a href="/">网站统计</a></p>
</footer>
<script src="../public/home/js/silder.js"></script>
</body>
</html>